<template>
   <div class="box">
      <div class="header">
        <van-nav-bar title="首页" />
      </div>
      <div class="content">
           <ul>
              <li v-for="item in list" :key="item.id" @click="$router.push('/detail/'+item.id)">
                  <div><img :src="item.image" alt=""></div>
                  <div>
                      <p class="van-multi-ellipsis--l2">{{item.title}}</p>
                      <p>￥{{item.price}}</p>
                  </div>
              </li>
           </ul>

           <van-skeleton>
  <template #template>
    <div :style="{ display: 'flex', width: '100%' }">
      <van-skeleton-image />
      <div :style="{ flex: 1, marginLeft: '16px' }">
        <van-skeleton-paragraph row-width="60%" />
        <van-skeleton-paragraph />
        <van-skeleton-paragraph />
        <van-skeleton-paragraph />
      </div>
    </div>
  </template>
</van-skeleton>
      </div>
    </div>
</template>

<script setup>
import request from '@/utils/request'
import {ref,onMounted} from 'vue'
const list =  ref([])
onMounted(()=>{
    request.get('/list').then(res=>{
        if(res.data.code==200)
        {
            list.value=res.data.data
        }
    })
})
</script>

<style lang="scss" >
ul{
    column-count: 2;
    column-gap: 10px;
    li{
        break-inside: avoid;
        img{
            width: 100%;
        }
    }
}
</style>